<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="js/layui/css/layui.css" />
</head>
<body>
<div class="layui-form" action="" style="padding: 10px;text-align: center;margin-right: 70px">
    <div class="layui-form-item">
        <label class="layui-form-label">账号</label>
        <div class="layui-input-block">
            <input type="text"id="name" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="text" id="desc" class="layui-input">
        </div>
    </div>
    <button class="layui-btn" onclick="add()">确定</button>
</div>
<script src="js/jquery-1.8.1.min.js"></script>
<script src="js/layui/layui.all.js"></script>
<script>
    function add() {
        if(!$("#name").val()||!$("#desc").val()){
            layer.msg("请输入账号密码");
            return;
        }
        $.ajax({
            type: "POST",
            url: "../../user/addAdmin",
            data: {
                "account":$("#name").val(),
                "password":$("#desc").val(),
            },
            dataType: "json",
            success: function(data){
                if(data.code==0){
                    layer.closeAll();
                }
                layer.msg(data.msg);
            }
        });
    }
</script>
</body>
</html>